package com.example.android_demo01.activity;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Intent;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.PopupWindow;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.example.android_demo01.R;

public class custom_dialog01 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_custom_dialog01);
    }

    public void customBtnClick2(View view){
       Intent intent = new Intent(this, CustomActivityDialog.class);
       startActivity(intent);
    }

    PopupWindow popupWindow;
    public void customBtnClick(View view){
        LayoutInflater inflater = LayoutInflater.from(this);
        View myView = inflater.inflate(R.layout.activity_custom_dialog, null);

        popupWindow = new PopupWindow(myView, 600, 800); //px

        myView.findViewById(R.id.custom_dialog_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                popupWindow.dismiss();
                Toast.makeText(custom_dialog01.this, "点击了确定", Toast.LENGTH_SHORT).show();
            }
        });

        popupWindow.showAsDropDown(view, Gravity.LEFT, 300);
//        popupWindow.showAtLocation(view, Gravity.CENTER, 0,0);

    }

}
